package com.gitee.wsl.struct.grammar.parser.context.ext

import com.gitee.wsl.struct.grammar.parser.Parser
import com.gitee.wsl.struct.grammar.parser.ParsingScope
import com.gitee.wsl.struct.grammar.parser.combinator.tryOrNull


/**
 * Returns true if the parser executes successfully (consuming input) and false otherwise (not consuming any input).
 */
suspend fun ParsingScope.has(p: Parser<Any>): Boolean = checkPresent(p)

/**
 * Returns true if the parser executes successfully (consuming input) and false otherwise (not consuming any input).
 */
suspend fun ParsingScope.checkPresent(p: Parser<Any>): Boolean = tryOrNull(p) != null





